<template>

	<div class="user">
		<!--搜索表单-->
		<div class="common-seach-wrap">
			<el-form size="small" :inline="true" :model="formInline" class="demo-form-inline">
				<el-form-item label="最长签到天数">
					<el-select v-model="formInline.days" placeholder="最长签到天数">
						<el-option label="不限" :value="-1"></el-option>
						<el-option v-for="(item,index) in daysList" :key="index" :label="item"
							:value="index"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="签到时间">
					<div class="block">
						<span class="demonstration"></span>
						<el-date-picker size="small" v-model="formInline.createTime" type="daterange"
							value-format="YYYY-MM-DD" range-separator="至" start-placeholder="开始日期"
							end-placeholder="结束日期">
						</el-date-picker>
					</div>
				</el-form-item>
				<el-form-item label="会员信息">
					<el-input v-model="formInline.nickName" placeholder="请输入会员信息"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" icon="Search" @click="onSubmit">查询</el-button>
				</el-form-item>
			</el-form>
		</div>

		<div class="product-content">
			<el-form ref="form" :model="form" label-width="100px">
				<div class="table-wrap">
					<el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
						<el-table-column prop="user_id" label="ID"></el-table-column>
						<el-table-column prop="nickName" label="会员信息"></el-table-column>
						<el-table-column prop="minDate" label="首次签到时间"></el-table-column>
						<el-table-column prop="lastDate" label="上次签到时间"></el-table-column>
						<el-table-column prop="endDate" label="最后一次签到时间"></el-table-column>
						<el-table-column prop="totalDay" label="累积签到天数"></el-table-column>
						<el-table-column prop="continuousDays" label="最长签到天数"></el-table-column>
						<el-table-column prop="prize" label="签到奖励">
							<template #default="scope">
								<div>
									{{ scope.row.points }}积分;
									<div v-for="(item, index) in scope.row.coupon" :key="index">
										<text class="orange">{{ item.name }}</text> x{{
              item.coupon_num
            }};
									</div>
								</div>
							</template>
						</el-table-column>
					</el-table>
				</div>
			</el-form>
			<!--分页-->
			<div class="pagination">
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" background
					:current-page="curPage" :page-size="pageSize" layout="total, prev, pager, next, jumper"
					:total="totalDataNumber">
				</el-pagination>
			</div>
		</div>
	</div>
</template>
<script>
	import {
		getSignList
	} from '@/api/sign.js';
	export default {
		data() {
			return {
				formInline: {
					days: -1,
					nickName: "",
					create_time: "",
				},
				form: {},
				tableData: [],
				/*一页多少条*/
				pageSize: 20,
				/*一共多少条数据*/
				totalDataNumber: 0,
				/*当前是第几页*/
				curPage: 1,
				/*是否加载完成*/
				loading: true,
				/*搜索条件*/
				daysList: ['2天', '3天', '4天', '5天', '6天', '7天', '15天', '30天', '60天'],
				/*搜索条件*/
				signTime: ['最近7天', '最近15天', '最近30天', '自定义'],
			};
		},
		created() {
			/*获取列表*/
			this.getData();
		},
		methods: {
			/*获取列表*/
			getData() {
				let self = this;
				let Params = {};
				Params.page = self.curPage;
				Params.list_rows = self.pageSize;
				getSignList(Params, true)
					.then(data => {
						self.loading = false;
						self.tableData = data.data.list.data;
						self.totalDataNumber = data.data.list.total
					})
					.catch(error => {});
			},
			onSubmit() {
				let self = this;
				let Params = this.formInline;
				Params.page = self.curPage;
				Params.list_rows = self.pageSize;
				self.loading = true;
				getSignList(Params, true).then(data => {
					self.loading = false;
					self.tableData = data.data.list.data;
					self.totalDataNumber = data.data.list.total
				}).catch(error => {

				});
			},
			/*选择第几页*/
			handleCurrentChange(val) {
				let self = this;
				self.curPage = val;
				self.loading = true;
				self.getData();
			},

			/*每页多少条*/
			handleSizeChange(val) {
				this.curPage = 1;
				this.pageSize = val;
				this.getData();
			}
		}
	};
</script>

<style>
</style>